fix: check for non-int 0 fill values#3345
fix: check for non-int 0 fill values#3345ilan-gold wants to merge 9 commits intozarr-developers:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3345 +/- ##
==========================================
- Coverage 61.86% 61.85% -0.01%
==========================================
Files 85 85
Lines 10111 10112 +1
==========================================
Hits 6255 6255
- Misses 3856 3857 +1
🚀 New features to boost your workflow:
|
|
to test this, could we perhaps patch |
dstansby
left a comment
There was a problem hiding this comment.
Looks good to me - needs a release note entry, and I left one suggestion to improve the test too.
|
|
||
|
|
||
| @pytest.mark.parametrize("dtype", [np.int8, np.uint16, np.float32, int, float]) | ||
| @pytest.mark.parametrize("fill_value", [None, 0, 1]) |
There was a problem hiding this comment.
| @pytest.mark.parametrize("fill_value", [None, 0, 1]) | |
| @pytest.mark.parametrize("fill_value", [None, 0, 0.0, 1]) |
Worth explicitly including a float here?
There was a problem hiding this comment.
I think everything is cast anyway by dtype, so it shouldn't matter, no?
|
I've done some digging into this topic, I'll post in a bit but I would like to hold off on merging for a bit. |
|
Ok apologies, I know that Tom's PR supercedes this in many ways but for anyone curious, my worry was about how memory is allocated. I learned that import numpy as np
buf = np.arange(100_000, dtype=np.float64)
# cell 1
%%timeit full = np.full((1_000_000,), 0, dtype=np.float64)
full[900_000:] = buf
# cell 2
%%timeit zeros = np.zeros((1_000_000,), dtype=np.float64)
zeros[900_000:] = buf
# cell 3
%%timeit full = np.full((1_000_000,), 0, dtype=np.float64)
full.sum()
# cell 4
%%timeit zeros = np.zeros((1_000_000,), dtype=np.float64)
zeros.sum()
|

A bit of an "oops" from me, but hopefully this is more robust (than #3082)! It worked for my one example but testing this without using a spy object seems impossible (happy to contribute that though, or some other test).
TODO:
docs/user-guide/*.rstchanges/